import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'

const routes = [
    {
        path:'/home',
        redirect:'/',
    },
    {
        path: "/",
        name: "home",
        component: () => import("@/views/home/home2.vue"),
        meta: {
            title:'首页'
        }
    },
    {
        path:'/:pathMath(.*)*',
        name:'NotFound',
        component:() => import("@/views/error-page/404.vue") 
    }
]

const router = createRouter({
    history: createWebHistory(import.meta.env.VITE_PUBLIC_URL),
    routes,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return { top: 0 }
        }
    },
})

export default router